#define _CRT_SECURE_NO_WARNINGS 1


#include<iostream>
using namespace std;
const int N = 1e2 + 10;
int n, num[N], seat, k[N], sum[N][N];
int main()
{
    cin >> n;
    for (int i = 1;i <= n;i++)
        cin >> num[i];
    bool flag = true;
    while (flag)
    {
        flag = false;
        for (int i = 1;i <= n;i++)
        {
            if (++k[i] > num[i] * 10);
            else
            {
                if (seat && sum[i][k[i] - 1] == seat)
                    seat++;
                sum[i][k[i]] = ++seat;
                flag = true;
            }
        }
    }
    for (int i = 1;i <= n;i++)
    {
        cout << '#' << i << '\n';
        for (int j = 1;j <= num[i] * 10;j++)
        {
            cout << sum[i][j];
            if (j % 10)
                cout << ' ';
            else
                cout << '\n';
        }
    }
    return 0;
}